package Collection;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Collection2 {
    public static void main(String[] args) {
        Collection<String> coll = new ArrayList<>();
        coll.add("李大狗");
        coll.add("赵二狗");
        coll.add("王三狗");
        coll.add("刘四狗");
        Iterator<String> it = coll.iterator();
        //多态
        boolean b = it.hasNext();
        System.out.println(b);
        //判断集合中是否有元素
        String s =  it. next();
        System.out.println(s);
        //取出集合中的元素,并自动往下移
        while(it.hasNext())
        {
            s=it.next();
            System.out.println(s);
        }
        int[] arr = {1,2,3,4,5,6,7};
        for(int i :arr)
        {
            System.out.println(i);
        }
        ArrayList<String> list = new ArrayList<>();
        list.add("abc");list.add("abc");list.add("abc");list.add("abc");
        for(String sb:list)
        {
            System.out.println(sb);
        }

    }
}
